/**
 * <DL><DT>标题</DT></DL>
 *
 * @author liuboen
 * 
 * @since 2012-9-24
 * @version 1.0.0
 */
class FileTest {
	// 参考资料 :http://groovy.codehaus.org/groovy-jdk/java/io/File.html
	// 参考资料 http://hi.baidu.com/hemaoqing/item/56d6407897a10e3f71442353
		
	/**
	 * 全部一次性读取
	 * @param path
	 */
	static void readText(String path){
		def text = new File(path).getText();
		println text
	}

	/**
	 * 行读取
	 * @param path
	 */
	static  void readLine(String path){
		def textList = new File(path).readLines();
		textList.each { println it }
	}

	static void readCsv(String path){
		def csvList = new File(path).splitEachLine(",") {
			println "name=${it[0]} balance=${it[1]}";
		}
	}
	static void writeText(String path){
		new File(path).write("""
		This is
		just a test file
		to play with
		""");  
	}
	
	
	static main(args) {
		try{
			writeText("D:/foo.txt");
			readLine("D:/foo.txt");
			
			readCsv("D:/csvtest.csv")
		} catch(Exception e){
		}
	}
}
